<template>
  <div>
    姓名: <input type="text" v-model.trim="name" /><br /><br />
    年龄：<input type="number" v-model.number="age" /> <br /><br />
    身高：<input type="number" v-model.number="height" /> <br /><br />
    体重：<input type="number" v-model.number="weight" /> <br /><br />
    病史: <input type="text" v-model.trim="sick" /><br /><br />
    <button @click="fn">诊断</button> <span>{{ message }}</span>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: '',
      age: '',
      height: '',
      weight: '',
      sick: '',
      message: '',
      bmi:''
    }
  },
  methods: {
    fn() {
      
       this.bmi = this.weight/ (this.height*this.height)
     
      if (this.bmi <= 18.5) {
        console.log(this.bmi);
        this.message = `患者${this.name}的诊断结果为：体重过轻`
      } else if ( this.bmi <= 24.9) {
        console.log(this.bmi);
        this.message = `患者${this.name}的诊断结果为：正常`
      } else if ( this.bmi <= 29.9) {
        console.log(this.bmi);
        this.message = `患者${this.name}的诊断结果为：体重过重`
      }else{
        console.log(this.bmi);
        this.message = `患者${this.name}的诊断结果为： 肥胖`
      }
    
      // console.log(this.name)
      // console.log(this.age)
      // console.log(this.height)
      // console.log(this.weight)
      // console.log(this.sick)
      // console.log(this.message)
    },
  },
}
</script>

<style></style>
